import { createSlice } from '@reduxjs/toolkit';
import { fetchBallsSlice } from './balls.actions';

interface IBall {
    id: number,
    name: string,
    image: string,
    price: number,
    count: number,
    title: string,
    description: string
}

interface IInitialState {
    balls: IBall[]
}

const initialState: IInitialState = {
	balls: []
};

export const ballsSlice = createSlice({
	name:  'balls',
	initialState,
	reducers: {

	},
	extraReducers: (builder) => {
		builder.addCase(fetchBallsSlice.fulfilled, (state, action) => {
			state.balls = action.payload;
		});
	}
});

export default ballsSlice.reducer;
// export const userActions = userSlice.actions;